package ee.helmesWorkTest.backend.model.dao.factory;

import java.sql.Connection;
import ee.helmesWorkTest.backend.database.ConnectionManager;
import ee.helmesWorkTest.backend.database.ConnectionManagerInitializer;
import ee.helmesWorkTest.backend.database.DBType;
import ee.helmesWorkTest.backend.model.dao.PersonDAO;
import ee.helmesWorkTest.backend.model.dao.PersonSectorInvolvementDAO;
import ee.helmesWorkTest.backend.model.dao.SectorDAO;

public abstract class DAOFactory 
{
	private static DBType databaseType;
	
	static
	{
		ConnectionManagerInitializer.initializeConnectionManagerDBConnectionProperties();
		databaseType = ConnectionManager.getInstance().getDatabaseType();
	}
	
	public abstract PersonDAO getPersonDAOImpl(Connection dbConnection);
	public abstract PersonSectorInvolvementDAO getPersonSectorInvolvementDAOImpl(Connection dbConnection);
	public abstract SectorDAO getSectorDAOImpl(Connection dbConnection);
	
	public static DAOFactory getDAOFactory()
	{
		switch (getDBType()) 
		{
			case POSTGRESQL:
				return new PostgreSQLDAOFactory();
			case MYSQL:
				return null;
			default:
				return null;
		} 
	}
	
	private static DBType getDBType()
	{
		return databaseType;
	}
}
